<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ include file="../header.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<%@taglib prefix="myFn" uri="http://situ.com/rbac" %>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
</head>
<body>

	<form id="formId"  class="layui-form layui-form-pane" action="">
	  <div class="layui-form-item">
	    <label class="layui-form-label">客户名</label>
	    <div class="layui-input-block">
	      <input type="text" name="name" autocomplete="off" placeholder="请输入客户名" class="layui-input">
	    </div>
	  <div class="layui-form-item">
		 <label class="layui-form-label">性别</label>
		 <div class="layui-input-block">
			<input type="text" name="gender" lay-verify="required" placeholder="请输入性别：‘男’或‘女’" autocomplete="off" class="layui-input">
		 </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">办公电话</label>
	    <div class="layui-input-block">
	      <input type="text" name="office_phone" lay-verify="required" placeholder="请输入办公电话" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">手机</label>
	    <div class="layui-input-block">
	      <input type="text" name="phone" lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	 <%-- <div class="layui-form-item" pane="">
	    <label class="layui-form-label">商品状态</label>
	    <div class="layui-input-block">
	      <input type="radio" name="status" value="1" title="在售" checked="">
	      <input type="radio" name="status" value="2" title="下架">
	      <input type="radio" name="status" value="3" title="删除">
	    </div>
	  </div>--%>
	  
	  <%--<div class="layui-form-item" pane="">
	    <label class="layui-form-label">图片上传</label>
	    <div class="layui-upload layui-input-inline">
			  <div class="layui-upload-list">
			  	<input type="hidden" name="image"/>
			    <img class="layui-upload-img" width="150px" height="150px" id="image">
			    <p id="demoText"></p>
			  </div>
			  <button type="button" class="layui-btn" id="uploadImage">上传图片</button>
			</div>  
	  </div>
	   <div class="layui-form-item layui-form-text">
	    <label class="layui-form-label">商品详情</label>
	    <div class="layui-input-block">
	      <textarea id="detailId" placeholder="请输入内容" name="detail" class="layui-textarea"></textarea>
	    </div>
	  </div>--%>
	  <div class="layui-form-item">
    	<input class="layui-btn" type="button" onclick="submitForm()" value="添加"/>
  	   </div>
	</form>
	
	<script src="${path}/static/kindeditor/kindeditor.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">

		
		function submitForm() {
			$.post('${path}/customer/insert',
				$('#formId').serialize(),
				function(jsonResult) {
					console.log(jsonResult);
					if(jsonResult.ok) {
                        mylayer.confirm("添加成功，是否跳转到客户列表界面？", "${path}/customer/getCustomerPage");
						/*//当你在iframe页面关闭自身时获得当前弹出框的index索引
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg(
    						jsonResult.msg,
   							{icon : 1, time : 2000},
   							function() {// msg消失之后触发的函数

    						    // 关闭弹出层
                             	parent.layer.close(index);
                             	// 刷新父页面
                             	window.parent.location.reload();
   							}
    					);*/
					} else {
						mylayer.errorMsg(jsonResult.msg);
					}
			    },
			    'json');
		}
		
		KindEditor.ready(function(K) {
		    var kingEditorParams = {
		         afterBlur: function () { this.sync(); }
		    }
		    KindEditor.create('#detailId', kingEditorParams);
		});
	
	</script>
</body>
</html>